package com.uzai.console.web.profit;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.profit.prirewardrule.PriRewardRuleBatchSaveDto;
import com.uzai.console.dto.profit.prirewardrule.PriRewardRuleIdDto;
import com.uzai.console.dto.profit.prirewardrule.PriRewardRuleInfoDto;
import com.uzai.console.dto.profit.prirewardrule.PriRewardRuleQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.profit.PriRewardRuleService;
import com.uzai.console.vo.profit.prirewardrule.PriRewardRuleInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "定向规则",tags = "分佣管理|定向规则")
@ApiSort(4)
@RestController
public class PriRewardRuleContoller extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PriRewardRuleContoller.class);

    @Autowired
    private PriRewardRuleService priRewardRuleService;

    @ApiOperation(value = "分页查询定向规则列表", notes = "分页查询定向规则列表", response = PriRewardRuleInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/priRewardRule/findPriRewardRuleList")
    public Object findPriRewardRuleList(){
        PriRewardRuleQuery priRewardRuleQuery = new PriRewardRuleQuery();
        priRewardRuleQuery.setMerId(getLoginInfo().getMerId());
        priRewardRuleQuery.setSize(1000); //默认查询1000条
        return priRewardRuleService.findPriRewardRuleList(priRewardRuleQuery);
    }

    @ApiOperation(value = "查询定向规则详情", notes = "查询定向规则详情", response = PriRewardRuleInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/priRewardRule/findPriRewardRuleInfo")
    public Object findPriRewardRuleInfo(@RequestBody PriRewardRuleIdDto priRewardRuleIdDto){
        return priRewardRuleService.findPriRewardRuleInfo(priRewardRuleIdDto);
    }

    @SystemLogType(model = SystemModelEnum.PriRewardRule, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加定向规则", notes = "添加定向规则")
    @ApiOperationSupport(order = 3)
    @PostMapping("/priRewardRule/addPriRewardRule")
    public Object addPriRewardRule(@RequestBody PriRewardRuleInfoDto priRewardRuleInfoDto){
        priRewardRuleService.addPriRewardRule(priRewardRuleInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PriRewardRule, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改定向规则", notes = "修改定向规则")
    @ApiOperationSupport(order = 4)
    @PostMapping("/priRewardRule/updatePriRewardRule")
    public Object updatePriRewardRule(@RequestBody PriRewardRuleInfoDto priRewardRuleInfoDto){
        priRewardRuleService.updatePriRewardRule(priRewardRuleInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PriRewardRule, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除定向规则", notes = "删除定向规则")
    @ApiOperationSupport(order = 5)
    @PostMapping("/priRewardRule/deletePriRewardRule")
    public Object deletePriRewardRule(@RequestBody PriRewardRuleIdDto priRewardRuleIdDto){
        priRewardRuleService.deletePriRewardRule(priRewardRuleIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PriRewardRule, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量保存定向规则", notes = "批量保存定向规则")
    @ApiOperationSupport(order = 6)
    @PostMapping("/priRewardRule/batchSavePriRewardRule")
    public Object batchSavePriRewardRule(@RequestBody PriRewardRuleBatchSaveDto para){
        priRewardRuleService.batchSavePriRewardRule(para);
        return true;
    }

}
